/*  1:   */ package org.jetbrains.debugger.frame;
/*  2:   */ 
/*  3:   */

import com.intellij.openapi.util.AsyncResult;
import com.intellij.openapi.util.AsyncResult.Rejected;
import com.intellij.util.Consumer;
import com.intellij.util.PairConsumer;
import com.intellij.xdebugger.frame.XExecutionStack;
import com.intellij.xdebugger.frame.XSuspendContext;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.debugger.DebuggerViewSupport;
import org.jetbrains.debugger.EvaluateContext;
import org.jetbrains.debugger.Script;
import org.jetbrains.debugger.SuspendContext;
import org.jetbrains.debugger.values.StringValue;
import org.jetbrains.debugger.values.Value;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */
/* 12:   */
/* 13:   */
/* 14:   */
/* 15:   */
/* 16:   */
/* 17:   */
/* 18:   */
/* 19:   */
/* 20:   */ 
/* 21:   */ public class SuspendContextImpl
/* 22:   */   extends XSuspendContext
/* 23:   */ {
/* 24:   */   private final ExecutionStackImpl a;
/* 25:   */   private final SuspendContext b;
/* 26:   */   
/* 27:   */   protected SuspendContextImpl(@NotNull SuspendContext paramSuspendContext, @NotNull DebuggerViewSupport paramDebuggerViewSupport, @Nullable Script paramScript)
/* 28:   */   {
/* 29:22 */     this.a = new ExecutionStackImpl(paramSuspendContext, paramDebuggerViewSupport, paramScript);
/* 30:23 */     this.b = paramSuspendContext;
/* 31:   */   }
/* 32:   */   
/* 33:   */   public void clearObjectCaches()
/* 34:   */   {
/* 35:28 */     this.b.getValueManager().clearCaches();
/* 36:   */   }
/* 37:   */   
/* 38:   */   @NotNull
/* 39:   */   public XExecutionStack getActiveExecutionStack()
/* 40:   */   {
/* 41:34 */     ExecutionStackImpl tmp4_1 = this.a;
/* 42:34 */     if (tmp4_1 == null) {
/* 43:34 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/debugger/frame/SuspendContextImpl", "getActiveExecutionStack" }));
/* 44:   */     }
/* 45:34 */     return tmp4_1;
/* 46:   */   }
/* 47:   */   
/* 48:   */   public AsyncResult<String> evaluateLogExpression(@NotNull String paramString)
/* 49:   */   {
/* 50:38 */     if (paramString == null) {
/* 51:38 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/debugger/frame/SuspendContextImpl", "evaluateLogExpression" }));
/* 52:   */     }
/* 53:38 */     CallFrameView localCallFrameView = this.a.getTopFrame();
/* 54:39 */     if (localCallFrameView == null) {
/* 55:40 */       return new AsyncResult.Rejected("Top frame is null");
/* 56:   */     }
/* 57:42 */     return a(localCallFrameView.getCallFrame().getEvaluateContext(), paramString);
/* 58:   */   }
/* 59:   */   
/* 60:   */   private static String a(@Nullable String paramString)
/* 61:   */   {
/* 62:46 */     String str = "Can not evaluate log expression";
/* 63:47 */     return paramString != null ? str + ": " + paramString : str;
/* 64:   */   }
/* 65:   */   
/* 66:   */   @NotNull
/* 67:   */   private static AsyncResult<String> a(@NotNull EvaluateContext paramEvaluateContext, @NotNull String paramString)
/* 68:   */   {
/* 69:52 */     if (paramEvaluateContext == null) {
/* 70:52 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/debugger/frame/SuspendContextImpl", "evaluateExpression" }));
/* 71:   */     }
/* 72:52 */     if (paramString == null) {
/* 73:52 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/jetbrains/debugger/frame/SuspendContextImpl", "evaluateExpression" }));
/* 74:   */     }
/* 75:52 */     AsyncResult localAsyncResult = new AsyncResult();
/* 76:53 */     paramEvaluateContext.evaluate(paramString).doWhenDone(new Consumer()
/* 77:   */     {
/* 78:   */       public void consume(final Value paramAnonymousValue)
/* 79:   */       {
/* 80:56 */         if (paramAnonymousValue == null) {
/* 81:57 */           this.val$result.setDone("Log expression result doesn't have value");
/* 82:60 */         } else if (((paramAnonymousValue instanceof StringValue)) && (((StringValue)paramAnonymousValue).isTruncated())) {
/* 83:61 */           ((StringValue)paramAnonymousValue).getFullString().doWhenDone(new Runnable()
/* 84:   */           {
/* 85:   */             public void run()
/* 86:   */             {
/* 87:64 */               SuspendContextImpl.2.this.val$result.setDone(paramAnonymousValue.getValueString());
/* 88:   */             }
/* 89:64 */           }).doWhenRejected(new Runnable()
/* 90:   */           {
/* 91:   */             public void run()
/* 92:   */             {
/* 93:69 */               SuspendContextImpl.2.this.val$result.setRejected(SuspendContextImpl.a("whole expression result can not be loaded"));
/* 94:   */             }
/* 95:   */           });
/* 96:   */         } else {
/* 97:74 */           this.val$result.setDone(paramAnonymousValue.getValueString());
/* 98:   */         }
/* 99:   */       }
/* :0:74 */     }).doWhenRejected(new PairConsumer()
/* :1:   */     {
/* :2:   */       public void consume(Value paramAnonymousValue, String paramAnonymousString)
/* :3:   */       {
/* :4:81 */         if (paramAnonymousValue == null) {
/* :5:82 */           this.val$result.setRejected(SuspendContextImpl.a(paramAnonymousString));
/* :6:   */         } else {
/* :7:85 */           this.val$result.setRejected(SuspendContextImpl.a(paramAnonymousValue.getValueString()));
/* :8:   */         }
/* :9:   */       }
/* ;0:89 */     }); AsyncResult tmp119_118 = localAsyncResult;
/* ;1:89 */     if (tmp119_118 == null) {
/* ;2:89 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/debugger/frame/SuspendContextImpl", "evaluateExpression" }));
/* ;3:   */     }
/* ;4:89 */     return tmp119_118;
/* ;5:   */   }
/* ;6:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.debugger.frame.SuspendContextImpl

 * JD-Core Version:    0.7.0.1

 */